package com.idrem.views.common;

import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.EditText;

public class CustomEditText extends EditText {
	private Drawable dRight;
	private Rect rBounds;

	public CustomEditText(Context paramContext) {
		super(paramContext);
		setSingleLine();
	}

	public CustomEditText(Context paramContext, AttributeSet paramAttributeSet) {
		super(paramContext, paramAttributeSet);
		setSingleLine();
	}

	public CustomEditText(Context paramContext, AttributeSet paramAttributeSet,
			int paramInt) {
		super(paramContext, paramAttributeSet, paramInt);
		setSingleLine();
	}

	protected void finalize() throws Throwable {
		this.dRight = null;
		this.rBounds = null;
		super.finalize();
	}

	public boolean onTouchEvent(MotionEvent paramMotionEvent) {
		if ((paramMotionEvent.getAction() == 1) && (this.dRight != null)) {
			this.rBounds = this.dRight.getBounds();
			int i = (int) paramMotionEvent.getX();
			int j = (int) paramMotionEvent.getY();
			if ((i >= getWidth() - this.rBounds.width())
					&& (i <= getWidth() - getPaddingRight())
					&& (j >= getPaddingTop())
					&& (j <= getHeight() - getPaddingBottom())) {
				setText("");
				paramMotionEvent.setAction(3);
			}
		}
		return super.onTouchEvent(paramMotionEvent);
	}

	public void setCompoundDrawables(Drawable paramDrawable1,
			Drawable paramDrawable2, Drawable paramDrawable3,
			Drawable paramDrawable4) {
		if (paramDrawable3 != null)
			this.dRight = paramDrawable3;
		super.setCompoundDrawables(paramDrawable1, paramDrawable2,
				paramDrawable3, paramDrawable4);
	}
}